#pragma once
#include "../../Ode.h"

namespace Skill
{
	namespace Ode
	{
		ref class DWorld;
		ref class DVector3;
		namespace Joints
		{
			ref class DJoint;
			ref class DJointGroup;
			public ref class DJointGroup : DIUnmanagedPointer
			{
				INTERNAL_CLASS_DECLARATION_NO_FINALIZE(DJointGroup,dxJointGroup);
			private:
				List<DJoint^>^ _Joints;
			internal:
				void AddJoint(DJoint^ j);
				void RemoveJoint(DJoint^ j);				
			public:
				///<summary>
				/// Destroy a joint group.
				///</summary>
				!DJointGroup();

				UNMANAGEDPOINTER_DECLARATION();				

				///<summary>
				/// Create a joint group
				///</summary>				
				DJointGroup::DJointGroup()
				{
					_SetPointer(dJointGroupCreate(0),true);
					_Joints = gcnew List<DJoint^>();
				}

				///<summary>
				/// Empty a joint group.				
				/// All joints in the joint group will be destroyed,
				/// but the joint group itself will not be destroyed.
				///</summary>
				void Empty();

				///<summary>
				/// Access to joints by index
				///</summary>
				property DJoint^ default[int]
				{
					DJoint^ get(int index)
					{
						if(index < 0 || index >= _Joints->Count)
							return nullptr;
						return _Joints[index];
					}
				}
			};
		}
	}
}